package co.yixiang.yshop.module.crm.dal.mysql.crmbills;

import java.util.*;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.module.crm.dal.dataobject.crmbills.CrmBillsDO;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.crm.controller.admin.crmbills.vo.*;

/**
 * 账单 Mapper
 *
 * @author yshop
 */
@Mapper
public interface CrmBillsMapper extends BaseMapperX<CrmBillsDO> {

    default PageResult<CrmBillsDO> selectPage(CrmBillsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CrmBillsDO>()
                .likeIfPresent(CrmBillsDO::getStoreName, reqVO.getStoreName())
                .betweenIfPresent(CrmBillsDO::getBillingDate, reqVO.getBillingDate())
                .betweenIfPresent(CrmBillsDO::getRegisterCount, reqVO.getRegisterCount())
                .betweenIfPresent(CrmBillsDO::getExpenditure, reqVO.getExpenditure())
                .betweenIfPresent(CrmBillsDO::getUnitPrice, reqVO.getUnitPrice())
                .betweenIfPresent(CrmBillsDO::getRechargeAmount, reqVO.getRechargeAmount())
                .betweenIfPresent(CrmBillsDO::getBalance, reqVO.getBalance())
                .eqIfPresent(CrmBillsDO::getOwnerUserId, reqVO.getOwnerUserId())
                .orderByDesc(CrmBillsDO::getId));
    }

}